<UserControl x:Class="Supremacy.Client.Views.TradeRouteListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:scc="http://schemas.startreksupremacy.com/xaml/presentation">

  <UserControl.Resources>
    <Style x:Key="TradeRouteListItemContainerStyle"
           TargetType="{x:Type ListBoxItem}">
      <Setter Property="KeyboardNavigation.IsTabStop"
              Value="False" />
      <Setter Property="FocusVisualStyle"
              Value="{x:Null}" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListBoxItem}">
            <Grid Margin="0,4,0,0">
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Border x:Name="SelectionBorder"
                      Grid.Column="0"
                      BorderThickness="1"
                      CornerRadius="4"
                      Width="40"
                      Height="40"
                      VerticalAlignment="Top">
                <Border.BorderBrush>
                  <SolidColorBrush Color="{Binding Path=(scc:GameScreenViewBase.ClientContext).LocalPlayerEmpire.Civilization.Color, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type scc:GalaxyScreenView}}, FallbackValue=White}" />
                </Border.BorderBrush>
                <Border.Background>
                  <ImageBrush>
                    <ImageBrush.ImageSource>
                      <BitmapImage UriSource="vfs:///Resources/Images/ScreenIcons/trade_route.png" />
                    </ImageBrush.ImageSource>
                  </ImageBrush>
                </Border.Background>
              </Border>
              <ContentPresenter Grid.Column="1"
                                Margin="7,0,7,0" />
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected"
                       Value="True">
                <Setter TargetName="SelectionBorder"
                        Property="BorderBrush"
                        Value="White" />
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
      <Setter Property="ContentTemplate">
        <Setter.Value>
          <DataTemplate>
            <TextBlock DockPanel.Dock="Right"
                       VerticalAlignment="Top"
                       FontSize="14pt"
                       LineHeight="10pt">
            <TextBlock x:Name="TargetText"
                       Foreground="{StaticResource DefaultTextBrush}"
                       Text="{Binding Path=TargetColony.Name, Converter={StaticResource UpperCaseConverter}}" />
            <LineBreak />
            <TextBlock Foreground="{StaticResource HeaderTextBrush}">
              <TextBlock Text="{Binding Path=Credits, Converter={StaticResource UpperCaseConverter}}" />
              <TextBlock Text=" CREDITS" />
            </TextBlock>
          </TextBlock>
          <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=TargetColony}"
                         Value="{x:Null}">
              <Setter TargetName="TargetText"
                      Property="Text"
                      Value="UNASSIGNED" />
            </DataTrigger>
          </DataTemplate.Triggers>
        </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </UserControl.Resources>

  <ListBox x:Name="PART_TradeRouteList"
           DockPanel.Dock="Top"
           FontSize="14pt"
           Focusable="False"
           KeyboardNavigation.TabNavigation="None"
           KeyboardNavigation.DirectionalNavigation="None"
           KeyboardNavigation.IsTabStop="False"
           Foreground="{StaticResource DefaultTextBrush}"
           Background="Transparent"
           BorderThickness="0"
           ScrollViewer.HorizontalScrollBarVisibility="Disabled"
           ScrollViewer.VerticalScrollBarVisibility="Auto"
           ItemsSource="{Binding Path=TradeRoutes, Mode=OneWay}"
           SelectedItem="{Binding Path=SelectedTradeRoute, Mode=TwoWay}"
           ItemContainerStyle="{StaticResource TradeRouteListItemContainerStyle}" />

</UserControl>
